//SPDX-FileCopyrightText: Copyright 2025-2025 深圳市同心圆网络有限公司
//SPDX-License-Identifier: GPL-3.0-only

import { invoke } from "@tauri-apps/api/core";
import type { LlmProviderInfo } from "./ai_provider";

export type AdminAddLlmProviderRequest = {
    admin_session_id: string;    
    provider_info: LlmProviderInfo;
};

export type AdminAddLlmProviderResponse = {
    code: number;    
    err_msg: string;
};

export type AdminUpdateLlmProviderRequest = {
    admin_session_id: string;  
    provider_info: LlmProviderInfo;
};

export type AdminUpdateLlmProviderResponse = {
    code: number;    
    err_msg: string;
};

export type AdminRemoveLlmProviderRequest = {
    admin_session_id: string;    
    provider_id: string;
};

export type AdminRemoveLlmProviderResponse = {
    code: number;  
    err_msg: string;
};


// 增加供应商
export async function add_llm_provider(request: AdminAddLlmProviderRequest): Promise<AdminAddLlmProviderResponse> {
    const cmd = 'ai_provider_admin_api_cmds_add_llm_provider';
    console.log(`%c${cmd}`, 'color:#0f0;', request);
    return invoke<AdminAddLlmProviderResponse>(cmd, {
        request,
    });
}

// 更新供应商
export async function update_llm_provider(request: AdminUpdateLlmProviderRequest): Promise<AdminUpdateLlmProviderResponse> {
    const cmd = 'ai_provider_admin_api_cmds_update_llm_provider';
    console.log(`%c${cmd}`, 'color:#0f0;', request);
    return invoke<AdminUpdateLlmProviderResponse>(cmd, {
        request,
    });
}

// 删除供应商
export async function remove_llm_provider(request: AdminRemoveLlmProviderRequest): Promise<AdminRemoveLlmProviderResponse> {
    const cmd = 'ai_provider_admin_api_cmds_remove_llm_provider';
    console.log(`%c${cmd}`, 'color:#0f0;', request);
    return invoke<AdminRemoveLlmProviderResponse>(cmd, {
        request,
    });
}